/**
Group: efl/check:toggle (@since 1.23)
	 Part Text: efl.offtext
	 Part Text: efl.ontext
	 Part Text: efl.text
	 Part Swallow: efl.content
	 Signal: efl,content,set
	 Signal: efl,content,unset
	 Signal: efl,state,disabled
	 Signal: efl,state,enabled
	 Signal: efl,state,selected
	 Signal: efl,state,unselected
	 Signal: efl,text,set
	 Signal: efl,text,unset
Group: efl/check (@since 1.23)
	 Part Text: efl.text (required)
	 Part Swallow: efl.content (required)
	 Signal: efl,content,set
	 Signal: efl,content,unset
	 Signal: efl,state,disabled
	 Signal: efl,state,enabled
	 Signal: efl,state,selected
	 Signal: efl,state,unselected
	 Signal: efl,text,set
	 Signal: efl,text,unset
*/
#define ICON         1
#define LABEL        2
#define MASK         3
#define DISABLE      4
#define PRESSED      8
#define BACKGROUND  16

group { name: "efl/check";
   data.item: "version" "123";
   script {
      BUTTONMODE_SCRIPT2
   }
   parts {
      part { name: "shadow"; type: SPACER;
         description { state: "default";
         }
         desc { "pressed"; inherit;
         }
         desc { "disabled"; inherit;
         }
      }
      rect { "icon_clip";
         desc { "default";
            color: 255 255 255 255; // no cc
         }
         desc { "pressed"; inherit;
            color: 255 255 255 255; // no cc
         }
         desc { "disabled"; inherit;
            color: 255 255 255 64; // no cc
         }
      }
      swallow { "efl.background"; nomouse;
         required;
         desc { "default";
            rel.to: "shadow";
            visible: 0;
         }
         desc { "visible";
            inherit: "default";
             visible: 1;
         }
      }
      swallow { "efl.content"; nomouse;
         clip_to: "icon_clip";
         scale: 1;
         desc { "default";
            fixed: 1 0;
            align: 0.0 0.5;
            rel1.to_x: "base";
            rel2.to_x: "base";
            rel1.offset: 4 4;
            rel1.relative: 1.0 0.0;
            rel2.relative: 0.0 1.0;
            rel2.offset: 4 -5;
            visible: 0;
            offscale;
         }
         desc { "visible"; inherit;
            fixed: 1 0;
            aspect: 1.0 1.0;
            min: ICMIN ICMIN;
            visible: 1;
            min: ICMIN ICMIN;
         }
         desc { "icononly"; inherit;
            fixed: 0 0;
            align: 0.5 0.5;
            rel2.relative: 1.0 1.0;
            rel2.offset: -5 -5;
            rel2.to_x: "";
            visible: 1;
            min: ICMIN ICMIN;
         }
      }
      part { name: "base"; type: RECT;
         scale: 1;
         description { state: "default";
            fixed: 1 0;
            color_class: "/bg/normal/check/base";
            align: 0.0 0.5;
            min: 13 13;
            max: 13 13;
            rel1.offset: 4 4;
            rel2.relative: 0.0 1.0;
            rel2.offset: 4 -5;
            aspect: 1.0 1.0; aspect_preference: VERTICAL;
            offscale;
         }
         desc { "pressed"; inherit;
            color_class: "/bg/pressed/check/base";
         }
         desc { "disabled"; inherit;
            color_class: "/bg/disabled/check/base";
         }
      }
      part { name: "ck_check";
         clip_to: "ck_selected";
         scale: 1;
         description { state: "default" 0.0;
            fixed: 0 0;
            rel.to: "base";
            image.normal: "i-check";
            min: 15 15;
            max: 15 15;
            visible: 0;
            color_class: "/fg/normal/check/check";
            fixed: 1 1;
         }
         description { state: "pressed" 0.0;
            inherit: "default" 0.0;
            color_class: "/fg/pressed/check/check";
            visible: 1;
         }
         description { state: "selected" 0.0;
            inherit: "default" 0.0;
            color_class: "/fg/selected/check/check";
            visible: 1;
         }
      }
      part { name: "ck_selected"; type: RECT;
         description { state: "default" 0.0;
            rel.to: "base";
         }
         description { state: "disabled" 0.0;
            inherit: "default" 0.0;
            color: 255 255 255 153; // no cc
         }
      }
      text { "efl.text"; nomouse;
         scale: 1;
         desc { "default";
            fixed: 0 1;
            color_class: "/fg/normal/check/text";
            rel1.offset: 0 4;
            rel1.relative: 1.0 0.0;
            rel1.to_x: "efl.content";
            rel2.offset: -5 -5;
            text { font: FN; size: 10;
               align: 0.0 0.5;
               min: 0 0;
            }
            visible: 0;
            offscale;
            min: 0 ICMIN;
         }
         desc { "visible"; inherit;
            fixed: 0 0;
            rel1.offset: 4 4;
            text.min: 1 1;
            text.ellipsis: -1;
            visible: 1;
         }
         desc { "pressed_visible"; inherit;
            fixed: 0 0;
            color_class: "/fg/pressed/check/text";
            rel1.offset: 4 4;
            text.min: 1 1;
            text.ellipsis: -1;
            visible: 1;
         }
         desc { "textonly"; inherit;
            fixed: 0 0;
            text.min: 1 1;
            text.ellipsis: -1;
            visible: 1;
         }
         desc { "pressed_textonly"; inherit;
            fixed: 0 0;
            color_class: "/fg/pressed/check/text";
            text.min: 1 1;
            text.ellipsis: -1;
            visible: 1;
         }
         desc { "disabled_visible"; inherit;
            fixed: 0 0;
            color_class: "/fg/disabled/check/text";
            rel1.offset: 4 4;
            text.min: 1 1;
            text.ellipsis: -1;
            visible: 1;
         }
         desc { "disabled_textonly"; inherit;
            fixed: 0 0;
            color_class: "/fg/disabled/check/text";
            text.min: 1 1;
            text.ellipsis: -1;
            visible: 1;
         }
      }
      rect { "event";
         ignore_flags: ON_HOLD;
         desc { "default";
            color: 0 0 0 0; // no cc
         }
         desc { "disabled"; inherit;
            visible: 0;
         }
      }
   }
   programs {
      EFL_UI_CLICKABLE_PART_BIND(event)
      program { signal: "mouse,down,1"; source: "event";
         script {
            new buf[32]; new Float:val;
            get_state(PART:"ck_check", buf, 32, val);
            if (!strcmp(buf, "default")) { run_program(PROGRAM:"snd-check-on"); }
            else { run_program(PROGRAM:"snd-check-off"); }
         }
      }
      program { signal: "efl,state,selected"; source: "efl";
         action:  STATE_SET "selected" 0.0;
         target: "ck_check";
      }
      program { signal: "efl,state,unselected"; source: "efl";
         action:  STATE_SET "default" 0.0;
         target: "ck_check";
      }
      program { name: "snd-check-on";
         action: PLAY_SAMPLE "wood-tap1" 1.0 INPUT;
      }
      program { name: "snd-check-off";
         action: PLAY_SAMPLE "wood-tap2" 1.0 INPUT;
      }
      program { signal: "mouse,down,1"; source: "event";
         after: "button_click_anim";
      }
      program { signal: "mouse,down,1"; source: "event";
         action: STATE_SET "pressed" 0.0;
         target: "ck_check";
      }
      program { name: "button_click_anim";
         script { flag_set(PRESSED); }
      }
      program { signal: "mouse,up,1"; source: "event";
         action: STATE_SET "default" 0.0;
         target: "ck_check";
      }
      program { signal: "mouse,up,1"; source: "event";
         script { flag_unset(PRESSED); }
      }
      program { signal: "efl,text,set"; source: "efl";
         script { flag_set(LABEL); }
      }
      program { signal: "efl,text,unset"; source: "efl";
         script { flag_unset(LABEL); }
      }
      program { signal: "efl,content,set"; source: "efl";
         script { flag_set(ICON); }
      }
      program { signal: "efl,content,unset"; source: "efl";
         script { flag_unset(ICON); }
      }
      program { signal: "efl,state,disabled"; source: "efl";
         script { flag_set(DISABLE); }
      }
      program { signal: "efl,state,enabled"; source: "efl";
         script { flag_unset(DISABLE); }
      }
      program { signal: "efl,state,disabled"; source: "efl";
         action:  STATE_SET "disabled" 0.0;
         target: "ck_selected";
      }
      program { signal: "efl,state,enabled"; source: "efl";
         action:  STATE_SET "default" 0.0;
         target: "ck_selected";
      }
   }
}

group { name: "efl/check:toggle";
   script {
      public is_drag;
      public was_drag;
      public is_rtl;

      BUTTONMODE_SCRIPT2
   }
   parts {
      part { name: "shadow"; type: SPACER;
         description { state: "default";
         }
         desc { "pressed"; inherit;
         }
         desc { "disabled"; inherit;
         }
      }
      swallow { "efl.background"; nomouse;
         required;
         desc { "default";
            rel.to: "shadow";
            visible: 0;
         }
         desc { "visible";
            inherit: "default";
             visible: 1;
         }
      }
      rect { "icon_clip";
         desc { "default";
            color: 255 255 255 255; // no cc
         }
         desc { "pressed"; inherit;
            color: 255 255 255 255; // no cc
         }
         desc { "disabled"; inherit;
            color: 255 255 255 64; // no cc
         }
      }
      swallow { "efl.content"; nomouse;
         clip_to: "icon_clip";
         scale: 1;
         desc { "default";
            fixed: 1 0;
            align: 0.0 0.5;
            rel1.offset: 4 4;
            rel2.relative: 0.0 1.0;
            rel2.offset: 4 -5;
            visible: 0;
            offscale;
         }
         desc { "visible"; inherit;
            fixed: 1 0;
            aspect: 1.0 1.0;
            visible: 1;
            min: ICMIN ICMIN;
         }
         desc { "icononly"; inherit;
            fixed: 0 0;
            align: 0.5 0.5;
            rel2.relative: 1.0 1.0;
            rel2.offset: -5 -5;
            rel2.to_x: "tog";
            rel2.relative: 0.0 1.0;
            visible: 1;
            min: ICMIN ICMIN;
         }
      }
      spacer { name: "tog"; scale: 1;
         description { state: "default" 0.0;
            fixed: 1 1;
            rel1.relative: 1.0 0.0;
            rel1.offset: -5 4;
            rel2.offset: -5 -5;
            align: 1.0 0.5;
            min: 88 15;
            max: 88 15;
            offscale;
         }
      }
      rect { name: "base";
         description { state: "default";
            fixed: 1 1;
            color_class: "/bg/normal/toggle/base";
            rel.to: "tog";
         }
         desc { "pressed"; inherit;
            color_class: "/bg/pressed/toggle/base";
         }
         desc { "disabled"; inherit;
            color_class: "/bg/disabled/toggle/base";
         }
      }
      spacer { name: "onrect";
         description { state: "default" 0.0;
            rel.to: "button";
            rel1.relative: -5.0 0.0;
            rel2.relative: 0.5 1.0;
         }
      }
      spacer { name: "offrect";
         description { state: "default" 0.0;
            rel.to: "button";
            rel1.relative: 0.5 0.0;
            rel2.relative: 6.0 1.0;
         }
      }
      text { name: "efl.offtext"; nomouse; scale: 1;
         clip_to: "tog_clip";
         description { state: "default" 0.0;
            fixed: 1 1;
            rel1.to: "button";
            rel1.relative: 1.0 0.0;
            rel1.offset: 4 0;
            rel2.to: "offrect";
            rel2.offset: -5 -1;
            offscale;
            color_class: "/fg/normal/toggle/text/off";
            text { font: FN; size: 10;
               min: 0 1;
               align: 0.5 0.5;
               text_class: "check_off_text";
               text: "OFF";
            }
         }
         description { state: "disabled" 0.0;
            inherit: "default" 0.0;
            color_class: "/fg/disabled/toggle/text/off";
         }
         description { state: "clicked" 0.0;
            inherit: "default" 0.0;
            color_class: "/fg/pressed/toggle/text/off";
         }
      }
      text { name: "efl.ontext"; nomouse; scale: 1;
         clip_to: "tog_clip";
         description { state: "default" 0.0;
            fixed: 1 1;
            rel1.to: "onrect";
            rel1.offset: 4 0;
            rel2.to: "button";
            rel2.relative: 0.0 1.0;
            rel2.offset: -5 -1;
            offscale;
            color_class: "/fg/normal/toggle/text/on";
            text { font: FN; size: 10;
               min: 0 1;
               align: 0.5 0.5;
               text_class: "check_on_text";
               text: "ON";
            }
         }
         description { state: "disabled" 0.0;
            inherit: "default" 0.0;
            color_class: "/fg/disabled/toggle/text/on";
         }
         description { state: "clicked" 0.0;
            inherit: "default" 0.0;
            color_class: "/fg/pressed/toggle/text/on";
         }
      }
      part { name: "tog_clip"; type: RECT;
         description { state: "default" 0.0;
            rel.to: "tog";
         }
      }
      part { name: "button"; type: RECT; scale: 1;
         clip_to: "tog_clip";
         dragable {
            x: 1 1 0;
            y: 0 0 0;
            confine: "tog";
         }
         description { state: "default" 0.0;
            fixed: 1 1;
            rel.to: "tog";
            min: 15 15;
            max: 15 99999;
            color: 0 0 0 0; // no cc
         }
      }
      rect { name: "base_but"; nomouse;
         description { state: "default" 0.0;
            rel.to: "button";
            color_class: "/fg/normal/toggle/button";
         }
         description { state: "clicked" 0.0;
            inherit: "default" 0.0;
            color_class: "/fg/pressed/toggle/button";
         }
         description { state: "disabled" 0.0;
            inherit: "default" 0.0;
            color_class: "/fg/disabled/toggle/button";
         }
      }
      rect { name: "button_events";
         dragable.events: "button";
         description { state: "default" 0.0;
            color: 0 0 0 0; // no cc
         }
      }
      text { "efl.text"; nomouse;
         scale: 1;
         desc { "default";
            fixed: 0 1;
            color_class: "/fg/normal/toggle/text";
            rel1.offset: 0 4;
            rel1.relative: 1.0 0.0;
            rel1.to_x: "efl.content";
            rel2.offset: -5 -5;
            rel2.relative: 0.0 1.0;
            rel2.to_x: "tog";
            text { font: FN; size: 10;
               align: 0.5 0.5;
               min: 0 0;
            }
            visible: 0;
            offscale;
            min: 0 ICMIN;
         }
         desc { "visible"; inherit;
            fixed: 0 0;
            rel1.offset: 4 4;
            text.min: 1 1;
            text.ellipsis: -1;
            visible: 1;
         }
         desc { "pressed_visible"; inherit;
            fixed: 0 0;
            color_class: "/fg/pressed/toggle/text";
            rel1.offset: 4 4;
            text.min: 1 1;
            text.ellipsis: -1;
            visible: 1;
         }
         desc { "textonly"; inherit;
            fixed: 0 0;
            text.min: 1 1;
            text.ellipsis: -1;
            visible: 1;
         }
         desc { "pressed_textonly"; inherit;
            fixed: 0 0;
            color_class: "/fg/pressed/toggle/text";
            text.min: 1 1;
            text.ellipsis: -1;
            visible: 1;
         }
         desc { "disabled_visible"; inherit;
            fixed: 0 0;
            color_class: "/fg/disabled/toggle/text";
            rel1.offset: 4 4;
            text.min: 1 1;
            text.ellipsis: -1;
            visible: 1;
         }
         desc { "disabled_textonly"; inherit;
            fixed: 0 0;
            color_class: "/fg/disabled/toggle/text";
            text.min: 1 1;
            text.ellipsis: -1;
            visible: 1;
         }
      }
      rect { "event2";
         desc { "default";
            color: 0 0 0 0; // no cc
            visible: 0;
         }
         desc { "disabled"; inherit;
            visible: 1;
         }
      }
      rect { "event"; repeat;
         ignore_flags: ON_HOLD;
         desc { "default";
            color: 0 0 0 0; // no cc
         }
         desc { "disabled"; inherit;
            visible: 0;
         }
      }
   }
   programs {
      EFL_UI_CLICKABLE_PART_BIND("event")
      program { signal: "efl,state,selected"; source: "efl";
         script {
            new Float:drag;
            if (get_int(is_rtl) == 0) { drag = 100.0; }
            else                      { drag = 0.0; }
            set_drag(PART:"button", drag, 0.0);
         }
      }
      program { signal: "efl,state,unselected"; source: "efl";
         script {
            new Float:drag;
            if (get_int(is_rtl) == 0) { drag = 0.0; }
            else                      { drag = 100.0; }
            set_drag(PART:"button", drag, 0.0);
         }
      }
      program { signal: "mouse,clicked,1"; source: "button";
         script {
            new Float:dx, Float:dy;
            get_drag(PART:"button", dx, dy);
            if (!get_int(was_drag)) {
               if (dx > 0.5) {
                  set_drag(PART:"button", 0.0, 0.0);
               } else {
                  set_drag(PART:"button", 1.0, 0.0);
               }
               if (((get_int(is_rtl) == 1) && (dx <= 0.5)) ||
                   (get_int(is_rtl) == 0) && (dx > 0.5)) {
                  emit("efl,action,unselect", "efl");
               } else {
                  emit("efl,action,select", "efl");
               }
            }
         }
      }
      program { signal: "drag"; source: "button";
         script {
            set_int(is_drag, 1);
         }
      }
      program { signal: "mouse,down,1"; source: "button";
         script {
            set_int(was_drag, 0);
            set_int(is_drag, 0);
         }
      }
      program { signal: "mouse,up,1"; source: "button";
         script {
            new Float:dx, Float:dy;
            get_drag(PART:"button", dx, dy);
            if (get_int(is_drag)) {
               if (dx > 0.5) {
                 set_drag(PART:"button", 1.0, 0.0);
               } else {
                 set_drag(PART:"button", 0.0, 0.0);
               }
               if (((get_int(is_rtl) == 1) && (dx <= 0.5)) ||
                   (get_int(is_rtl) == 0) && (dx > 0.5)) {
                 emit("efl,action,select", "efl");
               } else {
                 emit("efl,action,unselect", "efl");
               }
               set_int(was_drag, 1);
               set_int(is_drag, 0);
            }
         }
      }
      program { signal: "mouse,down,1"; source: "button";
         action: STATE_SET "clicked" 0.0;
         target: "base_but";
         target: "efl.ontext";
         target: "efl.offtext";
      }
      program { signal: "mouse,up,1"; source: "button";
         action: STATE_SET "default" 0.0;
         target: "base_but";
         target: "efl.ontext";
         target: "efl.offtext";
      }
      program { signal: "efl,text,set"; source: "efl";
         script { flag_set(LABEL); }
      }
      program { signal: "efl,text,unset"; source: "efl";
         script { flag_unset(LABEL); }
      }
      program { signal: "efl,content,set"; source: "efl";
         script { flag_set(ICON); }
      }
      program { signal: "efl,content,unset"; source: "efl";
         script { flag_unset(ICON); }
      }
      program { signal: "efl,state,disabled"; source: "efl";
         script { flag_set(DISABLE); }
      }
      program { signal: "efl,state,enabled"; source: "efl";
         script { flag_unset(DISABLE); }
      }
      program { signal: "edje,state,rtl"; source: "edje";
         script {
            set_int(is_rtl, 1);
         }
      }
      program { signal: "edje,state,ltr"; source: "edje";
         script {
            set_int(is_rtl, 0);
         }
      }
   }
}
